package sky.com.util
{
	import flash.events.Event;
	import flash.media.Sound;
	import flash.media.SoundChannel;

	public class SoundFactory
	{
		//private static var soundFactioryInstane:SoundFactoryl;
		private static var _bgSoundUrl:String="sound/Normal.mp3"
		private static var _bgSound:Sound;
		private static var _bgSoundChannel:SoundChannel;
		
		public function SoundFactory()
		{
		}
		
		
		
		public static function playBgSound():void{
			if(_bgSound==null){
				_bgSound=new MySound(_bgSoundUrl).getSound();			
			}
			_bgSoundChannel=_bgSound.play();
			_bgSoundChannel.addEventListener(Event.SOUND_COMPLETE,playBgSoundComplete);	
		}
		
		private static function playBgSoundComplete(e:Event):void{
			_bgSoundChannel.removeEventListener(Event.SOUND_COMPLETE,playBgSoundComplete);
			_bgSoundChannel=_bgSound.play();
			_bgSoundChannel.addEventListener(Event.SOUND_COMPLETE,playBgSoundComplete);	
		}
		
		
		
		public static function stopBgSound():void{
			_bgSoundChannel.removeEventListener(Event.SOUND_COMPLETE,playBgSoundComplete);
			_bgSoundChannel.stop();
			
		}
		
		public static function playNewSound(url:String):void{
			new MySound(url).getSound().play();
		}
		
		
	}
}